<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	String basePath = request.getContextPath();
%>
<!DOCTYPE>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>车辆信息列表</title>
<script type="text/javascript" src="<%=basePath%>/resources/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" src="<%=basePath%>/resources/js/commonUtil.js"></script>
<script type="text/javascript" src="<%=basePath%>/resources/js/validateUtil.js"></script>
<link rel="stylesheet" href="<%=basePath%>/resources/css/main.css">
<script type="text/javascript">
	$(function(){
		$("#edit").click(function() {
			var selectIds = getSelectedIds();
			if (selectIds.length == 0 || selectIds.length > 1) {
				alert("请选择一条被修改的记录!");
				return false;
			}
			
			 window.location.href = "<%=basePath%>/employee/input?employeeId=" + selectIds[0];
		});
		
		$("#delete").click(function() {
			var selectIds = getSelectedIds();
			if (selectIds == '' || typeof selectIds == 'undefined' || selectIds.length == 0) {
				alert("请选择要被删除的记录!");
				return false;
			}
			
			//ajax异步请求删除数据
			$.ajax({
				async: true,
				url: "<%=basePath%>/employee/delete",
				data : "employeeIds=" + selectIds,
				type : "post",
				dataType : "json",
				success : function(reply) {
					alert(reply.replyMsg);
					if (reply.replyCode == 0 || replyCode == '0') {
						 window.location.href = "<%=basePath%>/employee/findAll";
					}
				},
				error : function(reply) {
					alert(reply.replyCode);
					alert(reply.replyMsg);
				}
			});
		});
	});

	function getSelectedIds() {
		var ids = $("input[name=employeId]");
		var selectIds = new Array();
		var idx = 0;
		for (var i = 0; i < ids.length; i++) {
			if (ids[i].checked) {
				selectIds[idx] = ids[i].value;
				idx++;
			}
		}
		return selectIds;
	}
</script>
</head>
<body>
	<div align="center">
	<table class="listTab">
		<thead>
			<tr>
				<td colspan="8">
					<div align="left">
						<a href="<%=basePath%>/employee/input" id="add" name="add">新 增</a>
						<a href="javascript:void();" id="edit" name="edit">修 改</a>
						<a href="javascript:void();" id="delete" name="delete">删 除</a>
					</div>
				</td>
			</tr>
			<tr>
				<th><input type="checkbox" name="checkAll" id="checkAll"></th>
				<th>用户名</th>
				<th>姓名</th>
				<th>身份</th>
				<th>手机号</th>
				<th>微信号</th>
				<th>邮箱</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach var="employee" items="${employeeList }">
				<tr>
					<td><input type="checkbox" name="employeId" value="${employee.employeeId }"></td>
					<td>${employee.nickName }</td>
					<td>${employee.realName }</td>
					<td>${employee.popedom }</td>
					<td>${employee.popedom }</td>
					<td>${employee.weixin }</td>
					<td>${employee.email }</td>
				</tr>
			</c:forEach>
			<tr>
				<td colspan="8">
					<a href="#">首页</a>
					<a href="#">上一页</a>
					<a href="#">下一页</a>
					<a href="#">末页</a>
				</td>
			</tr>
		</tbody>
	</table>
	</div>
</body>
</html>